package util;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class Business {
    public List<Business>listAllBusiness(){
        //查询所有商家信息
        List <Business> list = new ArrayList<Business>();
        String sql="select* from business";
        Connection conn=DBUtil.getConnection();
        Statement st = null;
        ResultSet rs = null;
        try{
            st= conn.createStatement();
            rs= st.executeQuery(sql);
            while(rs.next()){
                Business bs = new Business();
                bs.setBusiness_id(rs.getInt("business id"));
                bs.setBusiness_name(rs.getString("business_name");
                bs.setBusiness_address(rs.getString("business_address"));
                bs.setBusiness_ info(rs.getString("business_info"));
                bs.setBusiness_starPrice(rs.getDouble("starPrice"));
                bs.setBusiness_deliveryPrice(rs.getDouble("deliveryPrice");
                list.add(bs);
            }
        } catch(SQLException e){
//TODO 自动生成的 catch 块
            e.printStackTrace();
        }finally{
            DBUtil.close(conn,st,rs);
        }
        return list;
    }
}
